<?php

namespace App\Http\Controllers\rootcontroller\friendcontroller;

use App\Http\Controllers\Controller;
use App\Services\PushServiceInterFace;
use Illuminate\Support\Facades\Log;
use App\Models\DawnUser;
use App\Pojo\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\DB;
use App\Models\DawnZhjyUser;
use App\Models\ScheduleTask;
use App\Services\ScheduleServiceInterFace;
class FriendController extends Controller{

    protected $pushService;

    public function __construct(PushServiceInterFace $pushServiceInterFace)
    {
        $this->pushService = $pushServiceInterFace;
    }

    public function getAllFriendDetails(Request $request){
        $data = $request->validate([
            'current' => 'required|integer',
            'pageSize' => 'required|integer',
        ]);
        $result = $this->pushService->getFriendList( $data);
        return Response::success($result, '获取好友列表成功', 200);
    }

    public function editFriendDetails(Request $request){
        $data = $request->validate([
            'id' => 'required|integer',
            'remark' => 'required|string',
        ]);
        $result = $this->pushService->editFriendDetails($data);
        return $result;
    }

    public function deleteFriendDetails(Request $request){
        $request->validate([
            'ids' => 'required|array',
        ]);
        $ids = $request->input('ids');
        foreach ($ids as $id) {
            $data = [
                    'friendId' => $id['friendId'],
                    'appId' => $id['appId'],
                    'appName' => $id['appName'],
                    'name' => $id['name'],
                    'remark' => $id['remark'],
                    'token' => $id['token'],
                ];
            $this->pushService->deleteFriendDetails($data);
        }
        return Response::success();

    }   
}